{% include "../header.html" %}

<div id="content">
    <div class="container">
        <p>
            <form action="/user/login" method="post">
                <div><label>username:</label><input type="text" name="username" /></div>            
                <div><label>password:</label><input type="password" name="password" /></div>
                <button type="button" id="formButton">submit</button>
            </form>
            <script type="text/javascript">
                $('#formButton').click(function(){
                    var $form    = $(this).closest('form');
                    console.log($form);
                    $.post($form.prop('action'), $form.serialize(), function(json){
                        
                        if(json.code > 0)
                        {
                            return alert('error:' + json.message);
                        }

                        if(!alert("success:"+json.message))
                        {
                            location.href="/";
                        }

                    });
                });
            </script>
        </p>
    </div>
</div>

{% include "../footer.html" %}
